#include <iostream>
#include <string>

int main() {
    
    std::string s;
    std::cin >> s;
    std::string s1 = "";

    for (char& ch : s) {
        if (ch == '}') {
            s1 += ch;
        }
        if (ch == '}') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '}') {
                    s1 = s1.substr(0, s1.length() - 1);
                }
            }
        }
        if (ch == '[') {
            s1 += ch;
        }
        if (ch == ']') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '[') {
                    s1 = s1.substr(0, s1.length() - 1);
                }
            }
        }
        std::cout << s1 << std::endl;
        if (s1.length() == 0) {
            std::cout << "True" << std::endl;
        } else {
            std::cout << "False" << std::endl;
        }
    }

    return 0;
}